package com.bnq.logc.action

import com.bnq.logc.LogcLevel
import com.bnq.logc.utils.DateUtil

open class WriteAction(
    val level:Int,
    val tag:String,
    val log:String,
    val localTime:Long,
    val threadName:String,
    val isMainThread:Boolean,
) : LogAction {
    override fun isValid():Boolean {
        return log.isNotEmpty()
    }

    fun isDangerousEvent():Boolean = level == LogcLevel.ERROR || level == LogcLevel.SOS

    fun getLogMessage():String{
        val sb = java.lang.StringBuilder()
        sb.append(DateUtil.formatDateTime(localTime)).append("        ")
            .append(threadName).append("        ")
            .append(tag).append("        ")
            .append(LogcLevel.getLevelName(level)).append("        ")
            .append(log)
            .append("\n")
        val message = sb.toString()
        return message
    }

}